﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QntPlatform.BinanceApi.DApi
{
    public partial class DApiClient
    {

        /// marginAsset币种,pair交易对,只支持其中一个
        public IEnumerable<PositionRisk> GetPositionRisk(string marginAsset = null, string pair = null)
        {
            var req = CreateReq(Prefix + "positionRisk");
            if (!string.IsNullOrWhiteSpace(marginAsset))
                req.AddParameter("marginAsset", marginAsset);
            else if (!string.IsNullOrWhiteSpace(pair))
                req.AddParameter("pair", pair);

            return req.Get<IEnumerable<PositionRisk>>().CheckResp(log);
        }

    }

    /** <summary>
      {
        "symbol": "BTCUSD_201225",  // 交易对
        "positionAmt": "0", // 头寸数量,符号代表多空方向, 正数为多,负数为空
        "entryPrice": "0.0",    // 开仓均价
        "markPrice": "0.00000000",  // 当前标记价格
        "unRealizedProfit": "0.00000000",   // 持仓未实现盈亏
        "liquidationPrice": "0",    // 参考强平价格
        "leverage": "125",  // 当前杠杆倍数
        "maxQty": "50",  // 当前杠杆倍数允许的数量上限(标的数量)
        "marginType": "cross",  // 逐仓模式或全仓模式
        "isolatedMargin": "0.00000000", // 逐仓保证金
        "isAutoAddMargin": "false",
        "positionSide": "BOTH"  // 持仓方向
    }
     * </summary>
     */
    public class PositionRisk : DApiDto
    {
        public string symbol { get; set; }
        public decimal positionAmt { get; set; }
        public decimal entryPrice { get; set; }
        public decimal markPrice { get; set; }
        public decimal unRealizedProfit { get; set; }
        public decimal liquidationPrice { get; set; }
        public int leverage { get; set; }
        public int maxQty { get; set; }
        public string marginType { get; set; }
        public decimal isolatedMargin { get; set; }
        public string isAutoAddMargin { get; set; }
        public CreateOrderDto.PositionSideType positionSide { get; set; }
    }



}
